﻿using AutoMapper;
using Infra_Common.redis;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using xiaodingmarket_application.Interfaces;
using xiaodingmarket_Domain.Commands.Sell;
using xiaodingmarket_Domain.Interfaces.IRepository;
using xiaodingmarket_Domain_core.Bus;
using xiaodingmarket_Infra_Data.Repository.EventStore;

namespace xiaodingmarket_application.Service
{
    public class SellService : ISellService
    {
        private readonly IMapper _mapper;
        private readonly ICommodityRepository _commodityRepository;
        private readonly IEventStoreRepository _eventStoreRepository;
        private readonly IMediatorHandler Bus;
        private readonly RedisClient redis;

        public SellService(IMapper mapper,
                                  ICommodityRepository commodityRepository,
                                  IMediatorHandler bus,
                                  IEventStoreRepository eventStoreRepository,
                                  RedisClient reviewRedis)
        {
            _mapper = mapper;
            _commodityRepository = commodityRepository;
            Bus = bus;
            _eventStoreRepository = eventStoreRepository;
            redis = reviewRedis;
        }
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        public void WantAndTobeFriend(string access_token,Guid  friendid,Guid comodityid,Guid wanterid)
        {
            Bus.SendCommand(new WantAndTobeFriendCommand(access_token, friendid, comodityid, wanterid));
        }


    }
}
